#pragma once
#include "HashTable.h"
namespace lzb
{
	template<class K,class V>
	class unordered_map
	{
		struct MapKeyOfT
		{
			const K& operator()(const pair<const K,V>& kv)
			{
				return kv.first;
			}
		};
	public:
		typedef typename hash_bucket::HashTable<K, pair<const K, V>, MapKeyOfT>::iterator iterator;
		typedef typename hash_bucket::HashTable<K, pair<const K, V>, MapKeyOfT>::const_iterator const_iterator;
		iterator begin()
		{
			return _hashtable.begin();
		}
		iterator end()
		{
			return _hashtable.end();
		}
		const_iterator begin() const
		{
			return _hashtable.begin();
		}
		const_iterator end() const
		{
			return _hashtable.end();
		}
		pair<iterator,bool> insert(const pair<K, V>& kv)
		{
			return _hashtable.Insert(kv);
		}
		V& operator[](const K& key)
		{
			pair<iterator, bool> ret = _hashtable.Insert(make_pair(key, V()));
			return ret.first->second;
		}
	private:
		hash_bucket::HashTable<K,pair<const K,V>,MapKeyOfT> _hashtable;
	};

}